package com.mooc.fuxi.ui.news;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.mooc.fuxi.imgload.ImageLoad;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class NewsBannerAdapter extends BannerAdapter<String, NewsBannerAdapter.NewsBannerViewHolder> {

    public NewsBannerAdapter(List<String> datas) {
        super(datas);
    }

    @Override
    public NewsBannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        ImageView imageView = new ImageView(parent.getContext());
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
        imageView.setLayoutParams(lp);
        return new NewsBannerViewHolder(imageView);

    }

    @Override
    public void onBindView(NewsBannerViewHolder holder, String data, int position, int size) {
        ImageLoad.getInstance().loadMatchImg(data,holder.imageView);
    }

    public static class NewsBannerViewHolder extends RecyclerView.ViewHolder {

        ImageView imageView;

        public NewsBannerViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = (ImageView) itemView;
        }
    }

}
